/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CartPanel.java
 *
 * Created on Feb 17, 2012, 1:21:32 PM
 */
package dkgg2012group22imat.view;

import dkgg2012group22imat.controller.CartPanelController;
import java.awt.Color;
import javax.swing.OverlayLayout;

/**
 *
 * @author jonas
 */
public class CartPanel extends javax.swing.JPanel {

    CartPanelController controller;
    /** Creates new form CartPanel */
    public CartPanel() {
        initComponents();
        controller = new CartPanelController(this);
    }
    
    public CartWithProductsPanel getCartWithProductsPanel(){
        return cartWithProductsPanel;
    }
    
    public void setTotalPriceText(String text) {
        this.totalLabel.setText(text);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        totalLabel = new javax.swing.JLabel();
        toggleFavouriteCart = new javax.swing.JButton();
        gotoCheckout = new javax.swing.JButton();
        cartWithProductsPanel = new dkgg2012group22imat.view.CartWithProductsPanel();

        setName("Form"); // NOI18N
        setPreferredSize(new java.awt.Dimension(290, 637));
        setLayout(new java.awt.BorderLayout());

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(dkgg2012group22imat.view.DKGG2012Group22iMatApp.class).getContext().getResourceMap(CartPanel.class);
        jPanel1.setBackground(resourceMap.getColor("jPanel1.background")); // NOI18N
        jPanel1.setAlignmentX(0.0F);
        jPanel1.setAlignmentY(0.0F);
        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setPreferredSize(new java.awt.Dimension(290, 52));

        jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel1.setForeground(resourceMap.getColor("jLabel1.foreground")); // NOI18N
        jLabel1.setIcon(resourceMap.getIcon("jLabel1.icon")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addContainerGap(20, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        add(jPanel1, java.awt.BorderLayout.NORTH);

        jPanel2.setAlignmentX(0.0F);
        jPanel2.setAlignmentY(0.0F);
        jPanel2.setName("jPanel2"); // NOI18N
        jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS));

        totalLabel.setFont(resourceMap.getFont("totalLabel.font")); // NOI18N
        totalLabel.setForeground(resourceMap.getColor("totalLabel.foreground")); // NOI18N
        totalLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        totalLabel.setIcon(resourceMap.getIcon("totalLabel.icon")); // NOI18N
        totalLabel.setText(resourceMap.getString("totalLabel.text")); // NOI18N
        totalLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        totalLabel.setName("totalLabel"); // NOI18N
        jPanel2.add(totalLabel);

        toggleFavouriteCart.setFont(resourceMap.getFont("toggleFavouriteCart.font")); // NOI18N
        toggleFavouriteCart.setForeground(resourceMap.getColor("toggleFavouriteCart.foreground")); // NOI18N
        toggleFavouriteCart.setIcon(resourceMap.getIcon("toggleFavouriteCart.icon")); // NOI18N
        toggleFavouriteCart.setText(resourceMap.getString("toggleFavouriteCart.text")); // NOI18N
        toggleFavouriteCart.setToolTipText(resourceMap.getString("toggleFavouriteCart.toolTipText")); // NOI18N
        toggleFavouriteCart.setBorderPainted(false);
        toggleFavouriteCart.setDisabledIcon(resourceMap.getIcon("toggleFavouriteCart.disabledIcon")); // NOI18N
        toggleFavouriteCart.setDisabledSelectedIcon(resourceMap.getIcon("toggleFavouriteCart.disabledSelectedIcon")); // NOI18N
        toggleFavouriteCart.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toggleFavouriteCart.setIconTextGap(0);
        toggleFavouriteCart.setMaximumSize(new java.awt.Dimension(290, 28));
        toggleFavouriteCart.setMinimumSize(new java.awt.Dimension(290, 28));
        toggleFavouriteCart.setName("toggleFavouriteCart"); // NOI18N
        toggleFavouriteCart.setPreferredSize(new java.awt.Dimension(290, 28));
        toggleFavouriteCart.setPressedIcon(resourceMap.getIcon("toggleFavouriteCart.pressedIcon")); // NOI18N
        toggleFavouriteCart.setRolloverIcon(resourceMap.getIcon("toggleFavouriteCart.rolloverIcon")); // NOI18N
        toggleFavouriteCart.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseExited(java.awt.event.MouseEvent evt) {
                toggleFavouriteCartMouseExited(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                toggleFavouriteCartMouseEntered(evt);
            }
        });
        toggleFavouriteCart.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toggleFavouriteCartActionPerformed(evt);
            }
        });
        jPanel2.add(toggleFavouriteCart);
        toggleFavouriteCart.setLayout(new OverlayLayout(toggleFavouriteCart));

        gotoCheckout.setBackground(resourceMap.getColor("gotoCheckout.background")); // NOI18N
        gotoCheckout.setForeground(resourceMap.getColor("gotoCheckout.foreground")); // NOI18N
        gotoCheckout.setIcon(resourceMap.getIcon("gotoCheckout.icon")); // NOI18N
        gotoCheckout.setText(resourceMap.getString("gotoCheckout.text")); // NOI18N
        gotoCheckout.setToolTipText(resourceMap.getString("gotoCheckout.toolTipText")); // NOI18N
        gotoCheckout.setAlignmentY(0.0F);
        gotoCheckout.setBorderPainted(false);
        gotoCheckout.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        gotoCheckout.setDisabledIcon(resourceMap.getIcon("gotoCheckout.disabledIcon")); // NOI18N
        gotoCheckout.setMaximumSize(new java.awt.Dimension(290, 75));
        gotoCheckout.setMinimumSize(new java.awt.Dimension(290, 75));
        gotoCheckout.setName("gotoCheckout"); // NOI18N
        gotoCheckout.setOpaque(true);
        gotoCheckout.setPreferredSize(new java.awt.Dimension(290, 75));
        gotoCheckout.setPressedIcon(resourceMap.getIcon("gotoCheckout.pressedIcon")); // NOI18N
        gotoCheckout.setRolloverIcon(resourceMap.getIcon("gotoCheckout.rolloverIcon")); // NOI18N
        gotoCheckout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                gotoCheckoutActionPerformed(evt);
            }
        });
        jPanel2.add(gotoCheckout);

        add(jPanel2, java.awt.BorderLayout.SOUTH);

        cartWithProductsPanel.setBackground(resourceMap.getColor("cartWithProductsPanel.background")); // NOI18N
        cartWithProductsPanel.setAlignmentX(0.0F);
        cartWithProductsPanel.setAlignmentY(0.0F);
        cartWithProductsPanel.setName("cartWithProductsPanel"); // NOI18N
        cartWithProductsPanel.setPreferredSize(new java.awt.Dimension(290, 500));
        add(cartWithProductsPanel, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents

private void toggleFavouriteCartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toggleFavouriteCartActionPerformed
controller.openSaveCartDialog();
}//GEN-LAST:event_toggleFavouriteCartActionPerformed

private void gotoCheckoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gotoCheckoutActionPerformed
controller.gotoCheckout();
}//GEN-LAST:event_gotoCheckoutActionPerformed

private void toggleFavouriteCartMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_toggleFavouriteCartMouseEntered
jLabel1.setForeground(new Color(0,0,0));
}//GEN-LAST:event_toggleFavouriteCartMouseEntered

private void toggleFavouriteCartMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_toggleFavouriteCartMouseExited
jLabel1.setForeground(new Color(102,102,102));
}//GEN-LAST:event_toggleFavouriteCartMouseExited

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private dkgg2012group22imat.view.CartWithProductsPanel cartWithProductsPanel;
    public javax.swing.JButton gotoCheckout;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    public javax.swing.JButton toggleFavouriteCart;
    private javax.swing.JLabel totalLabel;
    // End of variables declaration//GEN-END:variables
}
